#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>

int place(int a)
{
	int n = 1;
	while (a/10)
	{
		a = a/10;
		n++;
	}
	return n;
}

void div(int arr[6], int i, int n)
{
	for (int j = n-1; j >= 0;j--)
	{
		arr[j] = i % 10;
		i = i / 10;
	}
}

int main()
{
	int n = 0;
	for (int i = 0;i <= 100000;i++)
	{
		int sum = 0;
		int arr[6] = { 0 };
		n = place(i);
		div(arr,i,n);
		for (int j = 0;j < n;j++)
		{
			sum += pow(arr[j], n);
		}
		if (i == sum)
		{
			printf("%d ", i);
		}
	}
	return 0;
}